import requests
from bs4 import BeautifulSoup

# 设置请求头以模拟浏览器访问
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'}

# 目标URL
url = 'https://detail.zol.com.cn/1158/1157161/param.shtml'

try:
    # 发送GET请求
    response = requests.get(url, headers=headers)

    # 检查响应状态码是否为200（即成功）
    if response.status_code == 200:
        # 解析页面内容
        soup = BeautifulSoup(response.text, 'html.parser')

        # 打印页面标题作为测试
        print("Page Title:", soup.title.string)

        # 在这里添加你想要解析的具体元素代码
        # 例如，查找所有的表格或特定的div等

    else:
        print(f"Failed to retrieve the page. Status code: {response.status_code}")
except requests.RequestException as e:
    print(f"An error occurred: {e}")